/*
 * Logger.cpp
 *
 *  Created on: Oct 7, 2012
 *      Author: romina
 */

#include "Logger.h"


Logger::Logger(string path) : ArchivoDeTexto(path, RW){
	archivo.close();
	archivo.open(path.c_str(), std::fstream::out| ios::app);
}

void Logger::log(SEVERITY severity, string message){
	time_t rawtime;
	struct tm * timeinfo;
	char buffer [80];

	time ( &rawtime );
	timeinfo = localtime ( &rawtime );

	strftime (buffer,80,"%I:%M%p.",timeinfo);

	string text = string(buffer) + " " + message;

	switch (severity) {
		case ALERT:
			this->escribirLinea("ALERT: " + text);
			break;
		case CRITICAL:
			this->escribirLinea("CRITICAL: " + text);
			break;
		case DEBUG:
			this->escribirLinea("DEBUG: " + text);
			break;
		case ERR:
			this->escribirLinea("ERROR: " + text);
			break;
		case WARNING:
			this->escribirLinea("WARNING: " + text);
			break;
	}
}

Logger::~Logger() {
}

